import Vue from 'vue'
import VueRouter from 'vue-router'
import Index from '../components/IndexCom.vue'
import TableDataCom from '../components/TableCom.vue'
import ContentCom from '../components/ContentCom.vue'
import LoginCom from '../components/LoginCom.vue'
import GetSoftWareCode from '../components/GetSoftWareCode.vue'
import ApplyForTest from '../components/ApplyForTest.vue'
import UserManage from '../components/UserManage.vue'
import ParameterUnit from '../components/ParameterUnit.vue'

Vue.use(VueRouter)

const originalPush = VueRouter.prototype.push
//修改原型对象中的push方法
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}
//解决vue路由重复导航错误
//获取原型对象上的push函数


const routes = [
  {
    path: '/',
    redirect: "/index"
  },
  {
    path: "/login",
    name: "LoginCom",
    component: LoginCom
  },
  {
    path: '/index',
    name: 'home',
    component: Index,
    children: [
      {
        path: "/ContentCom",
        name: "ContentCom",
        component: ContentCom,
        children: [
          {
            path: "/TableDataCom:content",
            name: "TableDataCom",
            component: TableDataCom
          },
          {
            path:"/ApplyForTest",
            name:"ApplyForTest",
            component: ApplyForTest
          },
          {
            path:"/UserManage",
            name:"UserManage",
            component: UserManage
          },
          {
            path:"/ParameterUnit",
            name:"ParameterUnit",
            component: ParameterUnit
          },
          {
            path: '/',
            redirect: "/TableDataCom17"
          },
          {
            path: '/GetSoftWareCode:content',
            name: "GetSoftWareCode",
            component: GetSoftWareCode
          },
        ]
      },
      {
        path: '/',
        redirect: "/ContentCom"
      }
    ]
  }
]

const router = new VueRouter({
  routes
})

export default router
